﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Dropthings.DataAccess;

namespace Dropthings.Business.Activities.UserAccountActivities
{
    public partial class GetAspnetUserActivity : System.Workflow.ComponentModel.Activity
	{
        private static DependencyProperty UserNameProperty = DependencyProperty.Register("UserName", typeof(string), typeof(GetAspnetUserActivity));

        [ValidationOptionAttribute(ValidationOption.Required)]
        public string UserName
        {
            get { return (string)base.GetValue(UserNameProperty); }
            set { base.SetValue(UserNameProperty, value); }
        }

        public static readonly DependencyProperty aspnet_UserProperty =
            DependencyProperty.Register("aspnet_User", typeof(aspnet_User), typeof(GetAspnetUserActivity));

        public aspnet_User aspnet_User
        {
            get { return (aspnet_User)GetValue(aspnet_UserProperty); }
            set { SetValue(aspnet_UserProperty, value); }
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.aspnet_User = DatabaseHelper.GetSingle<aspnet_User, string>(DatabaseHelper.SubsystemEnum.User,
                    this.UserName, LinqQueries.CompiledQuery_GetUserFromUserName);

            return ActivityExecutionStatus.Closed;
        }

        public GetAspnetUserActivity()
		{
			InitializeComponent();
		}
	}
}
